
@extends('admin.master')

@section('title', '添加账号')

@section('title_top')
    @parent
    <div class="title_top">添加账号</div>
@stop
@section('equip_query')
<div class="title_edit">请按照提示填写信息</div>
@stop
@section('userinfo_tab')
<div class="edit_gb">
    <div class="add_line">
        <div class="account_name">账户名<input class="account_txt" type="text" placeholder="您的账户名"/><label class="requiredCharacter">*</label></div>
        <div class="passwd">密码<input class="pwd_txt" type="password" placeholder="不少于6个字符" /><label class="requiredCharacter">*</label></div>
    </div>
    <div class="edit_box">
        <div>姓名<input class="name_txt" type="text" placeholder="您的姓名"/></div>
        <div class="sex_box">
            <p>性别</p>
            <p class="sex_input_box"><span class="sex_input sex_add"></span></p>
            <div class="sex_down sex_a">
                <a>男</a>
                <a>女</a>
            </div>
        </div>
        <div class="clear"></div>
        <div>手机<input class="telepho_txt" type="text" placeholder="您常用的手机号码" /><label class="requiredCharacter">*</label></div>
        <div class="edit_btn">
            <a class="return_btn" href="javascript:history.go(-1);">返回</a>
            <a class="add_accbtn">添加</a>
        </div>
  </div>
</div>
@stop

@section('infor_promit')
@parent
<script type="text/javascript">
    //添加账号
    $(".add_accbtn").click(function(){
        var account_txt=$(".account_txt").val();
        var pwd_txt=$(".pwd_txt").val();
        var name_txt=$(".name_txt").val();
        var sex_add=$(".sex_add").html();
        var telepho_txt=$(".telepho_txt").val();
        if(telepho_txt!=""&&(/^1[34578]\d{9}$/.test(telepho_txt))){
            $.ajax({
                url:"/api/admin/add",
                type:"post",
                dataType:"json",
                data:{
                    username:account_txt,
                    password:pwd_txt,
                    name:name_txt,
                    sex:sex_add,
                    phone:telepho_txt
                },
                success:function(data){
                    if(data.status['errCode'] == 0){
                        hint1("成功添加账号！");
                        window.location.href = "/admin/user/index";
                    }else{
                        hint(data.status.message);
                    }
                },
                error:function(jqXHR, textStatus, errorThrown){
                    hint(jqXHR.responseText);
                }
            });
        }else{
            hint("手机号码输入有误，请正确输入！");
        }
        
    });

</script>
@stop
